import Router from 'koa-router';
import proxyService from '../../common/proxyService';
import {
  getWXSDKconfig,
  h5getCompanys, // 获取企业列表
  h5enterCompany, // 进入企业
  h5getAppaccounts, // 获取公众号列表
  h5getCompanyInfo, // 获取企业概况
  h5checkCreate,
} from '../../api/h5';
import { queryCurrVersion } from '../../api';

const router = new Router();

// 获取默认免费信息
router.get('/queryCurrVersion', async ctx => {
  const response = await proxyService.postProxy(ctx, queryCurrVersion);
  return (ctx.body = response);
});
// 获取jssdk基本配置
router.get('/getSdkConfig', async ctx => {
  delete ctx.requestParams.sessionId;
  const response = await proxyService.postProxy(ctx, getWXSDKconfig);
  return (ctx.body = response);
});

// 获取企业列表
router.get('/getCompanys', async ctx => {
  const response = await proxyService.postProxy(ctx, h5getCompanys);
  return (ctx.body = response);
});

// 进入企业
router.get('/enterCompany', async ctx => {
  const response = await proxyService.postProxy(ctx, h5enterCompany);
  return (ctx.body = response);
});

// 获取公众号列表
router.get('/getAppaccounts', async ctx => {
  const response = await proxyService.postProxy(ctx, h5getAppaccounts);
  return (ctx.body = response);
});

// 获取企业概况
router.post('/getCompanyInfo', async ctx => {
  const response = await proxyService.postProxy(ctx, h5getCompanyInfo);
  return (ctx.body = response);
});

// 判断用户是否可创建企业
router.get('/checkCreate', async ctx => {
  const response = await proxyService.postProxy(ctx, h5checkCreate);
  return (ctx.body = response);
});

export default router;
